<?php
use app\models\Activity;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;

/* @var $model \app\models\Activity */
/* @var $user \app\models\User */
/* @var $this \yii\web\View */

\app\assets\MuiPickerAsset::register($this);
$fieldLabels = [
    Activity::TYPE_ACTIVITY => [
        'title' => '活动主题',
        'company' => '主办方',
        'content' => '活动简介',
        'address' => '活动地点'

    ],
    Activity::TYPE_JOB => [
        'title' => '职位名称',
        'company' => '公司名称',
        'content' => '职位简介',
        'address' => '工作地点'
    ],
];
?>
<div class="mui-content">

    <div class="mui-content-padded">

        <?php $form = ActiveForm::begin(['options' => ['class' => 'formBox']]); ?>
            <div class="company-logo-input">
                <img src="<?= $user->getAvatar(); ?>"/>
            </div>

            <div class="input-row">
                <label><i class="ico ico-theme"></i><?= $fieldLabels[$model->type]['title']; ?></label>
                <?= $form->field($model, 'title')->textInput()->label(FALSE); ?>
            </div>

            <div class="input-row">
                <label><i class="ico ico-name"></i><?= $fieldLabels[$model->type]['company']; ?></label>
                <?= $form->field($model, 'company')->textInput()->label(FALSE); ?>
            </div>

            <?php if($model->cid != Activity::CID_JOB): ?>
            <div class="input-row">
                <label><i class="ico ico-start"></i>活动开始时间</label>
                <?= $form->field($model, 'start_time')->textInput(['placeholder' => '请选择开始时间', 'readonly' => 'readonly', 'class' => 'date_time form-control'])->label(FALSE); ?>
            </div>

            <div class="input-row">
                <label><i class="ico ico-end"></i>活动结束时间</label>
                <?= $form->field($model, 'end_time')->textInput(['placeholder' => '请选择结束时间', 'readonly' => 'readonly', 'class' => 'date_time form-control'])->label(FALSE); ?>
            </div>
            <?php endif; ?>

        <?php if(!$model->getIsActivity()): ?>
            <div class="input-row">
                <label><i class="ico ico-money"></i>薪资水平</label>
                <?= $form->field($model, 'salary')->textInput()->label(FALSE); ?>
            </div>

            <?php if($model->cid == Activity::CID_JOB): ?>
                <div class="input-row">
                <label><i class="ico ico-xl"></i>学历要求</label>
                <?= $form->field($model, 'tag')->textInput(['placeholder' => '请选择学历', 'readonly' => 'readonly', 'class' => 'tag form-control'])->label(FALSE); ?>
            </div>
            <?php endif; ?>

        <?php endif; ?>

        <div class="input-row input-row-group">
            <label><i class="ico ico-address">&nbsp;</i>

            </label>

            <div class="fflex">
                <?= $form->field($model, 'province_id')->hiddenInput()->label(FALSE); ?>
                <?= $form->field($model, 'province')->textInput(['placeholder' => '选择城市', 'readonly' => 'readonly', 'class' => 'province form-control'])->label(FALSE); ?>

                <?= $form->field($model, 'city_id')->hiddenInput()->label(FALSE); ?>
                <?= $form->field($model, 'city')->textInput(['placeholder' => '选择地区', 'readonly' => 'readonly', 'class' => 'city form-control'])->label(FALSE); ?>
            </div>
        </div>


            <?php if($model->cid != Activity::CID_SAI_SHI): ?>
            <div class="input-row">
                <label><i class="ico ico-address"></i><?= $fieldLabels[$model->type]['address']; ?></label>
                <?= $form->field($model, 'address')->textInput()->label(FALSE); ?>
            </div>
            <?php endif; ?>

            <div class="input-row textarea-row">
                <label><i class="ico ico-about"></i><?= $fieldLabels[$model->type]['content']; ?></label>
                <?= $form->field($model, 'content')->textarea(['rows' => 10])->label(FALSE); ?>
            </div>

            <?php if($model->getIsActivity()): ?>
            <div class="input-row2">
                <label>设置人数</label>
                <div class="fflex">
                    <div class="input-row2box">
                        <span class="title">人数</span>
                        <?= $form->field($model, 'number')->textInput(['placeholder' => '填0不限'])->label(FALSE); ?>
                    </div>
                    <div class="input-row2box">
                        <span class="title">单价</span>
                        <?= $form->field($model, 'price')->textInput(['placeholder' => '填0免费'])->label(FALSE); ?>
                        <span class="title2">元</span>
                    </div>
                </div>
            </div>
            <?php endif; ?>

            <div class="input-row2">
                <label>上传开篇海报</label>
            </div>

        <?= $this->render('/upload/index', [
            'name' => 'uploads',
            'thumbs' => $model->isNewRecord ? [] : $model->getThumbs(),
            'original_name' => 'original_image'
        ]); ?>

            <button redirect="/user/publish" type="submit" class="mui-btn mui-btn-blue mui-btn-block">发布</button>

        <?php ActiveForm::end(); ?>
    </div>
</div>

<?= \app\widgets\WxJsWidget::widget([]); ?>

